package com.hushow.plugin.main.smain.controller;

import com.hushow.plugin.main.smain.vo.response.*;
import com.hushow.plugin.main.smain.vo.request.*;
import com.hushow.plugin.main.smain.service.SmainService;
import org.springframework.web.bind.annotation.*;
import com.hucodex.rest.common.response.PageOutput;

import javax.annotation.Resource;
import java.util.List;
import javax.validation.Valid;

import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;

/**
 * (Smain)表控制层
 *
 * @author hushowly
 * @since 2025-08-06 09:06:29
 */
@Api(value = "接口", tags = "")
@RestController
@RequestMapping("/smain")
public class SmainController {

    /**
     * 服务对象
     */
    @Resource
    private SmainService smainService;

    /**
     * 分页查询所有数据
     *
     * @param listReq 查询实体
     * @return 所有数据
     */
    @ApiOperation(value = "分页查询所有数据", notes = "分页查询所有数据")
    @PostMapping("/listSmainByPage")
    public PageOutput<ListSmainByPageResp> listSmainByPage(@RequestBody ListSmainByPageReq listReq) {
        return this.smainService.listSmainByPage(listReq);
    }

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @ApiOperation(value = "通过主键查询单条数据", notes = "通过主键查询单条数据")
    @ApiImplicitParams(value = {@ApiImplicitParam(name = "id", value = "主键", required = true)})
    @GetMapping("/getSmainById")
    public SmainVo getSmainById(@RequestParam("id") String id) {
        return this.smainService.getSmainById(id);
    }

    /**
     * 新增数据
     *
     * @param addReq 实体对象
     * @return 新增结果
     */
    @ApiOperation(value = "新增数据", notes = "新增数据")
    @PostMapping("/addSmain")
    public SmainVo addSmain(@RequestBody @Valid AddSmainReq addReq) {
        return this.smainService.addSmain(addReq);
    }

    /**
     * 修改数据
     *
     * @param reqReq 实体对象
     * @return 修改结果
     */
    @ApiOperation(value = "修改数据", notes = "修改数据")
    @PutMapping("/updateSmain")
    public void updateSmain(@RequestBody @Valid UpdateSmainReq reqReq) {
        this.smainService.updateSmain(reqReq);
    }

    /**
     * 删除数据
     *
     * @param idList 主键结合
     * @return 删除结果
     */
    @ApiOperation(value = "删除数据", notes = "删除数据")
    @ApiImplicitParams(value = {@ApiImplicitParam(name = "idList", value = "主键集合", required = true)})
    @DeleteMapping("deleteSmainById")
    public Boolean deleteSmainById(@RequestParam("idList") List<Long> idList) {
        return this.smainService.removeByIds(idList);
    }
}
